<template>
  <div class="home-hot" ref="target">
    <HomePanel title="人气推荐" subTitle="人气爆款 不容错过">
        <!-- 面板内容 -->
        <Transition name="fade">
          <ul class="hot-list" v-if="hot.length">
              <li v-for="item in hot" :key="item.id">
              <RouterLink :to="`/product/${item.id}`">
                  <img v-lazy="item.picture" alt="">
                  <p class="name">{{item.title}}</p>
                  <p class="desc">{{item.alt}}</p>
              </RouterLink>
              </li>
          </ul>
          <HomeSkeleton v-else/>
        </Transition>
    </HomePanel>
  </div>
</template>

<script>
import HomePanel from './home-panel.vue'
import HomeSkeleton from './home-skeleton.vue'
import { findHot } from '@/api/home'
import { useLazyData } from '@/hooks'

export default {
  name: 'HomeNew',
  components: {
    HomePanel,
    HomeSkeleton
  },
  setup () {
    const { result, target } = useLazyData(findHot)
    return { hot: result, target }
  }
}
</script>

<style scoped lang="less">
.hot-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>
